package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.system.domain.ZtfMainTables;
import com.ruoyi.system.domain.dto.ZtfMainTablesDTO;
import com.ruoyi.system.result.PageResult;
import com.ruoyi.system.service.IZtfMainTablesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 智提分考试大师Controller
 * 
 * @author ruoyi
 * @date 2025-05-30
 */
@RestController
@RequestMapping("admin/system/course")
@Api(tags = "后台课程模块相关接口")
public class ZtfMainTablesController extends BaseController
{
    @Autowired
    private IZtfMainTablesService ztfMainTablesService;

    /**
     * 查询智提分考试大师列表
     */
//    @PreAuthorize("@ss.hasPermi('system:tables:list')")
//    @GetMapping("/list")
//    @ApiOperation("课程列表接口")
//    public TableDataInfo list(ZtfMainTables ztfMainTables)
//    {
//        startPage();
//        List<ZtfMainTables> list = ztfMainTablesService.selectZtfMainTablesList(ztfMainTables);
//        return getDataTable(list);
//    }


    //新的分页方法
    @PreAuthorize("@ss.hasPermi('system:tables:list')")
    @GetMapping("/list")
    @ApiOperation("新的课程列表接口")
    public AjaxResult list(ZtfMainTablesDTO ztfMainTablesDTO)
    {
        //返回分页数据
        PageResult pageResult  = ztfMainTablesService.newSelectZtfMainTablesList(ztfMainTablesDTO);
        return AjaxResult.success(pageResult);
    }

    /**
     * 导出智提分考试大师列表
     */
    @PreAuthorize("@ss.hasPermi('system:tables:export')")
    @Log(title = "智提分考试大师", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZtfMainTables ztfMainTables)
    {
        List<ZtfMainTables> list = ztfMainTablesService.selectZtfMainTablesList(ztfMainTables);
        ExcelUtil<ZtfMainTables> util = new ExcelUtil<ZtfMainTables>(ZtfMainTables.class);
        util.exportExcel(response, list, "智提分考试大师数据");
    }

    /**
     * 获取智提分考试大师详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:tables:query')")
    @GetMapping(value = "/{ztfid}")
    public AjaxResult getInfo(@PathVariable("ztfid") Long ztfids)
    {
        return success(ztfMainTablesService.selectZtfMainTablesByZtfid(ztfids));
    }

    /**
     * 新增智提分考试大师
     */
    @PreAuthorize("@ss.hasPermi('system:tables:add')")
    @Log(title = "智提分考试大师", businessType = BusinessType.INSERT)
    @ApiOperation("课程新增接口")
    @PostMapping
    public AjaxResult add(@RequestBody ZtfMainTables ztfMainTables)
    {

        ztfMainTables.setFastUUID(ztfMainTables.getDictCode());
        String uuid = IdUtils.simpleUUID();
        ztfMainTables.setZtfid(uuid);
        return toAjax(ztfMainTablesService.insertZtfMainTables(ztfMainTables));
    }

    /**
     * 修改智提分考试大师
     */
    @PreAuthorize("@ss.hasPermi('system:tables:edit')")
    @Log(title = "智提分考试大师", businessType = BusinessType.UPDATE)
    @PutMapping("/update")
    @ApiOperation("课程修改接口")
    public AjaxResult edit(@RequestBody ZtfMainTables ztfMainTables)
    {
        return toAjax(ztfMainTablesService.updateZtfMainTables(ztfMainTables));
    }

    /**
     * 删除智提分考试大师
     */
    @PreAuthorize("@ss.hasPermi('system:tables:remove')")
    @Log(title = "智提分考试大师", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ztfids}")
    @ApiOperation("课程删除接口")
    public AjaxResult remove(@PathVariable("ztfids") String[] ztfids)
    {
        return toAjax(ztfMainTablesService.deleteZtfMainTablesByZtfids(ztfids));
    }

}
